import { Button, Tooltip } from 'antd';
import { Fragment } from 'react';
import { PlusCircleOutlined, DeleteOutlined, EyeOutlined } from '@ant-design/icons';
import { stateOfRendering } from '../common';
import { history } from 'umi';
import { fieldFlowExport, getKeyRouter, getTenantID, priceFormat, renderTableText, tableSorter } from '@/utils';

// Table表格的配置
const getTableColumn = (valueObj, delSelectRow, showModal) => {
  return [
    {
      title: '资产名称',
      dataIndex: 'assetName',
      key: 'assetName',
      width: 120,
      fixed: 'left',
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '资产类型',
      dataIndex: 'brandTypeName',
      key: 'brandTypeName',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'brandTypeName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '资产编码',
      dataIndex: 'sourceTypeName',
      key: 'sourceTypeName',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'sourceTypeName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '所属仓库',
      dataIndex: 'assetStoreName',
      key: 'assetStoreName',
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetStoreName'),
      render: (text: string) => renderTableText(text, true),
    },
    {
      title: '规格参数',
      dataIndex: 'assetValue',
      key: 'assetValue',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'assetValue'),
      render: (text: number | any) => {
        return <span>{text ? priceFormat(text) : `0.00`}</span>;
      },
    },
    {
      title: '数量',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
    {
      title: '量化单位',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
    {
      title: '单价',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
    {
      title: '总价',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
    {
      title: '品牌',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
    {
      title: '来源类型',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
    {
      title: '使用人',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
    {
      title: '使用人部门',
      dataIndex: 'unitOfMeasurement',
      key: 'unitOfMeasurement',
      visible: true,
      width: 120,
      sorter: (a: any, b: any) => tableSorter(a, b, 'unitOfMeasurement'),
      render: (text: string) => {
        return <span>{text ? text : '--'}</span>;
      },
    },
    {
      title: (
        <div style={{ width: '100%', textAlign: 'center' }}>
          <Button
            type="link"
            disabled={valueObj.pageType == 'view'}
            size="small"
            onClick={showModal}
            icon={<PlusCircleOutlined />}
            className="manageBtntTxtStyle"
          >
            添加
          </Button>
        </div>
      ),
      dataIndex: 'operation',
      key: 'operation',
      width: 80,
      visible: true,
      unDrag: true,
      fixed: 'right',
      render: (_: string, record: Record<string, any>) => {
        return (
          <div className="counterpoartDelBtnStyle">
            <Button
              onClick={() => {
                delSelectRow(record);
              }}
              disabled={valueObj.pageType == 'view'}
              type={'link'}
              size={'small'}
              icon={<DeleteOutlined />}
              className={'manageBtntTxtStyle'}
            >
              删除
            </Button>
          </div>
        );
      },
    },
  ];
};

export { getTableColumn };
